<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>定义Promise类静态方法all,race</title>
  <script src="./promise.js"></script>
</head>
<body>
  <script>
    const promise1 = new MyPromise((resolve, reject) => {
      setTimeout(() => {
        resolve('p1')
      }, 1000)
    })
    const promise2 = new MyPromise((resolve, reject) => {
      setTimeout(() => {
        resolve('p2')
        // reject('fail')
      }, 2000)
    })
    MyPromise.all([promise1, promise2]).then(res => console.log(res), err => console.log(err))
    MyPromise.race([promise1, promise2]).then(res => console.log(res), err => console.log(err))
  </script>
</body>
</html>